<%@ page language="java" contentType="text/html; charset=UTF-8"   pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ include file="international.jsp" %> 
<jsp:useBean id="userService" class="com.brother.service.UserService"></jsp:useBean>
<%
String action = request.getParameter("action");
com.brother.model.Customer user = (com.brother.model.Customer)session.getAttribute(com.brother.Constants.LOGIN_SESSTION_NAME);
if(user == null)
	return;
if(user.getName().equalsIgnoreCase("safetycontrol")){
	return;
}
int updateResult = 0;
if(action != null && action.equalsIgnoreCase("changepassword")){
	String oldPass = request.getParameter("old_pass");
	String newPass = request.getParameter("new_pass");
	updateResult = userService.modifyPassword(newPass, user.getUserid()+"" ,oldPass);
}
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title><fmt:message key="manage.modify.password"/> - <fmt:message key="company.name"/></title>
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
<link rel="stylesheet" type="text/css" href="css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="css/grid-examples.css" />
<link rel="stylesheet" type="text/css" href="css/examples.css" />
 <script type="text/javascript" src="js/ext-base.js"></script>
 <script type="text/javascript" src="js/ext-all.js"></script>
<style type="text/css">
body{
background-color: #FFFFFF;
}
</style>
</head>
<body >

<script>
function check_password()
{
	if (form1.new_pass.value == "" ||
		 form1.new_pass2.value == "" ||
		 form1.old_pass.value == "")
	{
		alert("<fmt:message key="manage.password.not.empty"/>");
		return (false);
	}
		 
	if (form1.new_pass.value != form1.new_pass2.value)
	{
		alert("<fmt:message key="manage.password.must.same"/>");
		return (false);
	}
	return true;
}
</script>

<form name="form1" action="gps_password.jsp" method="post" onsubmit="javascript:return check_password();">
			<table align="center"  border="1" class="tableBorder1" cellpadding="3" width="100%">
			

								<tr>

					<td align="left" width="140"><fmt:message key="manage.old.password"/>:</td>
					<td><input type="Password" name="old_pass" value="" /></td>
				</tr>
				<tr>
					<td align="left"><fmt:message key="manage.new.password"/></td>
					<td><input type="Password" name="new_pass" value="" /></td>
				</tr>
				<tr>

					<td align="left"><fmt:message key="manage.confirm.password"/>:</td>
					<td><input type="Password" name="new_pass2" value="" /></td>
				</tr>
				<tr style="border:0px">
					<td colspan="2" style="border:0px" align="center">
						<input type="hidden" name="action" value="changepassword" />&nbsp;
						<%if(updateResult > 0) {%>
						<span style="font-weight:bold;"><fmt:message key="manage.change.success"/></span><%}else if(action != null){%>
						<span style="font-weight:bold;color:red"><fmt:message key="manage.change.failed"/></span>
						<%} %>
					</td>

				</tr>
				
			</table>
</form>
<table><tr>
<td width="150">&nbsp;</td>

<td><div id="submitBtn"></div>
						<script>
						Ext.onReady(function(){
							var button = new Ext.Button({renderTo:'submitBtn',type:'submit', 
								text:'<fmt:message key="manage.submit"/>',split: true,width:80,
								enableToggle:false});
							button.on('click',function(){
								if(check_password())
									document.forms[0].submit();
								});
								});
						</script></td>
<td><div id="cancelBtn"></div>
<script>
						Ext.onReady(function(){
							 button = new Ext.Button({renderTo:'cancelBtn',type:'button', 
								text:'<fmt:message key="form.cancel"/>',split: true,width:80,
								enableToggle:false});
								button.on('click',function(){
							    	top.settingWin.hide();
								});
						});
						</script>
</td>
</tr></table>

</body>
</html>
<%
com.brother.database.DataBase.closeThreadConnection();
%>